<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>{$_title}</h2>
    </div>
    <notempty name="trader" >
    	<form action="{:U('Trader/editTrader')}" method="post" class="form-horizontal">
    		<input type="hidden" name="id" value="{$trader.id}" />
    <else />
	    <form action="{:U('Trader/addTrader')}" method="post" class="form-horizontal">
    </notempty>
        <div class="form-item">
            <label class="item-label">名称<span class="check-tips">（基金经理真实姓名）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="{$trader.name|default=''}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">性别<span class="check-tips"></span></label>
            <div class="controls">
            	<select name="sex" class="input-large">
            		<foreach name="Think.config.SEX" key="key" item="val">
	            		<if condition="$key eq $trader['sex']">
			           		<option value="{$key}" selected>{$val}</option>
			           	<else />
	            			<option value="{$key}">{$val}</option>
	            		</if>
            		</foreach>
            	</select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">出生日期<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large date_picker"  readonly name="birthday" value="{:date('Y-m-d', $trader['birthday'])}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">学历<span class="check-tips"></span></label>
            <div class="controls">
            	<select name="education" class="input-large">
            		<foreach name="Think.config.EDUCATION" key="key" item="val">
	            		<if condition="$key eq $trader['education']">
			           		<option value="{$key}" selected>{$val}</option>
			           	<else />
	            			<option value="{$key}">{$val}</option>
	            		</if>
            		</foreach>
            	</select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">手机<span class="check-tips">（不可重复）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="mobile" value="{$trader.mobile|default=''}">
            </div>
        </div>
         <div class="form-item">
            <label class="item-label">选择头像<span class="check-tips"><a href="{:U('File/addFile', array('file_type' => 6))}">上传头像</a></span></label>
            <div class="controls">
               <div class="div-desc" id="avatar_id" style="width:500px;float:left;margin-right:10px;overflow-y:auto"></div>
               <div class="div-desc" style="width:500px;float:left;" id="yu_lan"></div>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">基金管理年限<span class="check-tips">（基金经理从事基金管理的年限）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="year" value="{$trader.year|default=''}">
            </div>
        </div>
        
        <div class="form-item">
            <label class="item-label">管理基金产品数量<span class="check-tips">（基金经理目前管理的基金产品数量）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="count" value="{$trader.count|default=''}">
            </div>
        </notempty>
        
        <div class="form-item">
            <label class="item-label">QQ<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="qq" value="{$trader.qq|default=''}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">微信<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="weixin" value="{$trader.weixin|default=''}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">基金经理概要<span class="check-tips"></span></label>
            <div class="controls">
            	<textarea class="div-desc" name="abstract">{$trader.abstract|default=''}</textarea>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">基金经理风格<span class="check-tips"></span></label>
            <div class="controls">
            	<textarea class="div-desc" name="abstract1">{$trader.abstract1|default=''}</textarea>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">基金经理业绩<span class="check-tips"></span></label>
            <div class="controls">
            	<textarea class="div-desc" name="abstract2">{$trader.abstract2|default=''}</textarea>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">基金经理简介<span class="check-tips"></span></label>
            <div class="controls">
            	<textarea class="input-large kind-editor" name="brief">{$trader.brief|default=''}</textarea>
            </div>
        </div>
        
        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>
<block name="style">
	<link href="__PUBLIC__/static/jquery-datetimepicker/jquery-datetimepicker.css" rel="stylesheet" media="screen">
	<link rel="stylesheet" href="__PUBLIC__/static/kindeditor/default/default.css" />
</block>
<block name="script">
	<script type="text/javascript" src="__PUBLIC__/static/jquery-datetimepicker/jquery-datetimepicker.js"></script>
	<script charset="utf-8" src="__PUBLIC__/static/kindeditor/kindeditor-min.js"></script>
	<script charset="utf-8" src="__PUBLIC__/static/kindeditor/zh_CN.js"></script>
    <script type="text/javascript">
		KindEditor.ready(function(K) {
			window.editor = K.create('textarea[class="kind-editor"]', {
				allowFileManager : true,
				uploadJson:"{:U('File/kinderUpload')}",
				minWidth:900,
				minHeight:300,
				afterBlur: function(){this.sync();},
			});
		});
		
		//日期时间插件
    	$('.date_picker').datetimepicker({
    		lang:'ch',
    		format:'Y-m-d',
    		timepicker:false,
    		allowBlank:true
		});
    
		//查询头像文件
		var file = "{$trader.avatar_id|default=0}";
    
		ajaxRequest("{:U('File/fileList1')}", {"file_type":6}, {"func":function(data){
			//处理查询结果
			var info = '';
			if(data && data.error == 0) {
				//记录已选中图片的url
				st = false;
				$.each(data.info, function(key, val){
					//记录初始图片
					
					//图片列表
					info += '<span class="avatar_file" style="cursor:pointer">';
					info += '<input type="radio" style="vertical-align:middle" value="'+val.id+'" data-url="'+val.url+'" name="avatar_id" ';
					if(file == val.id) {
						info += 'checked';
						st = val.url;
					}
					info += ' /> ' + val.name + '</span>';
					info += '<br/>';
				});
				$("#avatar_id").empty().append(info);
				
				//点击预览
				$('.avatar_file').click(function(){
					var img = '<img src="'+$(this).children('input').data('url')+'" style="max-width:500px;max-height:245px;"/>';
					$("#yu_lan").empty().append(img);
					$(this).children('input').prop('checked', 'true');
				});
				
				//已选中的图片
				if(st != false) $("#yu_lan").empty().append('<img src="'+st+'" style="max-width:500px;max-height:245px;"/>');
			} else {
				$("#avatar_id").empty().append('没有文件');
			}
		}});
		
        //导航高亮
        highlight_subnav('{:U('Trader/traderList')}');
    </script>
</block>
